//package com.ydkj.a37e_mall.Classes.Acitivity.BaseActivity;
//
//import android.app.Activity;
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.annotation.Nullable;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.AdapterView;
//import android.widget.BaseAdapter;
//import android.widget.BaseExpandableListAdapter;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.RelativeLayout;
//import android.widget.SeekBar;
//import android.widget.TextView;
//
//import com.bumptech.glide.Glide;
//import com.foamtrace.photopicker.PhotoPickerActivity;
//import com.foamtrace.photopicker.PhotoPreviewActivity;
//import com.foamtrace.photopicker.SelectModel;
//import com.foamtrace.photopicker.intent.PhotoPickerIntent;
//import com.foamtrace.photopicker.intent.PhotoPreviewIntent;
//import com.ydkj.a37e_mall.Classes.Model.Request.StroreimgReq;
//import com.ydkj.a37e_mall.R;
//import com.ydkj.a37e_mall.Resource.View.MyGridView;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Created by Administrator on 2017/1/16.
// */
//
//public class text extends Activity{
//    private Activity mActivity;
//    private ImageView img_back;
//    private TextView preservation;//保存
//
//    private EditText et_child_store_message_name, et_child_store_message_telephone, et_child_store_message_adress,
//            et_child_store_details_introduce, et_child_personal_details_material, et_personal_details_telephone,
//            et_child_personal_details_id, et_child_detailed_address_street, et_child_verification_code_num;
//    private TextView tv_child_store_thumbnail_num, tv_child_address, tv_child_verification_code_get;
//    private RelativeLayout rly_child_submit;
//    private SeekBar sb_child_change_alpha;
//    private MyGridView gridview_child_store_thumbnail, gridview_child_store_details, gridview_child_business_qualification;
//    private ImageView id_child_phone;
//
//
//    private static final int REQUEST_CAMERA_CODE = 11;
//    private static final int REQUEST_PREVIEW_CODE = 22;
//
//    private StoreManagementActivity.StoreimgAdapter storeimgAdapter;//门店缩略图
//    private List<StroreimgReq> stroreimglist;
//    private ArrayList<String> imagePaths = null;
//    private int columnWidth, selectimgcode;
//
//    @Override
//    protected void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.store_management);
//        mActivity = this;
//        init();
//    }
//
//    private void init() {
//        et_child_store_message_name = (EditText) mActivity.findViewById(R.id.et_child_store_message_name);
//        et_child_store_message_telephone = (EditText) mActivity.findViewById(R.id.et_child_store_message_telephone);
//        et_child_store_message_adress = (EditText) mActivity.findViewById(R.id.et_child_store_message_adress);
//        et_child_store_details_introduce = (EditText) mActivity.findViewById(R.id.et_child_store_details_introduce);
//        et_child_personal_details_material = (EditText) mActivity.findViewById(R.id.et_child_personal_details_material);
//        et_personal_details_telephone = (EditText) mActivity.findViewById(R.id.et_personal_details_telephone);
//        et_child_personal_details_id = (EditText) mActivity.findViewById(R.id.et_child_personal_details_id);
//        et_child_detailed_address_street = (EditText) mActivity.findViewById(R.id.et_child_detailed_address_street);
//        et_child_verification_code_num = (EditText) mActivity.findViewById(R.id.et_child_verification_code_num);
//
//        tv_child_store_thumbnail_num = (TextView) mActivity.findViewById(R.id.tv_child_store_thumbnail_num);
//        tv_child_address = (TextView) mActivity.findViewById(R.id.tv_child_address);
//        tv_child_verification_code_get = (TextView) mActivity.findViewById(R.id.tv_child_verification_code_get);
//
//        rly_child_submit = (RelativeLayout) mActivity.findViewById(R.id.rly_child_submit);
//        sb_child_change_alpha = (SeekBar) mActivity.findViewById(R.id.sb_child_change_alpha);
//        id_child_phone = (ImageView) mActivity.findViewById(R.id.id_child_phone);
//
//        gridview_child_store_thumbnail = (MyGridView) mActivity.findViewById(R.id.gridview_child_store_thumbnail);
//        gridview_child_store_details = (MyGridView) mActivity.findViewById(R.id.gridview_child_store_details);
//        gridview_child_business_qualification = (MyGridView) mActivity.findViewById(R.id.gridview_child_business_qualification);
//
//
//        stroreimglist = new ArrayList<>();
//        StroreimgReq req = new StroreimgReq();
//        req.setImgpath("");
//        stroreimglist.add(req);
//        storeimgAdapter = new StoreManagementActivity.StoreimgAdapter(stroreimglist);
//
//
//        img_back = (ImageView) mActivity.findViewById(R.id.img_back);
//        preservation = (TextView) mActivity.findViewById(R.id.preservation);
//
//        img_back.setOnClickListener(this);
//        preservation.setOnClickListener(this);
//    }
//
//    @Override
//    public void onClick(View view) {
//        switch (view.getId()) {
//            case R.id.img_back:
//                finish();
//                break;
//            case R.id.preservation://保存
//                break;
//        }
//    }
//
//
//    private class StoreManagementAdapter extends BaseExpandableListAdapter {
//        private List<String> group;
//        private List<List<String>> child;
//
//
//        public StoreManagementAdapter(List<String> group, List<List<String>> child) {
//
//            this.group = group;
//            this.child = child;
//        }
//
//        @Override
//        public int getGroupCount() {
//            return group.size();
//        }
//
//        @Override
//        public int getChildrenCount(int groupPosition) {
//            return child.get(groupPosition).size();
//        }
//
//        @Override
//        public Object getGroup(int groupPosition) {
//            return group.get(groupPosition);
//        }
//
//        @Override
//        public Object getChild(int groupPosition, int childPosition) {
//            return child.get(childPosition).get(childPosition);
//        }
//
//        @Override
//        public long getGroupId(int groupPosition) {
//            return groupPosition;
//        }
//
//        @Override
//        public long getChildId(int groupPosition, int childPosition) {
//            return childPosition;
//        }
//
//        /**
//         * 显示：group
//         */
//        @Override
//        public View getGroupView(final int groupPosition, boolean isExpanded,
//                                 View convertView, ViewGroup parent) {
//            StoreManagementActivity.StoreManagementAdapter.ViewHolder vh;
//            if (convertView == null) {
//                convertView = LayoutInflater.from(mActivity).inflate(
//                        R.layout.storemanagement_group_list, null);
//                vh = new StoreManagementActivity.StoreManagementAdapter.ViewHolder();
//
//                vh.img_group = (ImageView) convertView.findViewById(R.id.img_group);
//                vh.tv_group_storemanagement_name = (TextView) convertView.findViewById(R.id.tv_group_storemanagement_name);
//
//            } else {
//                vh = (StoreManagementActivity.StoreManagementAdapter.ViewHolder) convertView.getTag();
//            }
//            convertView.setTag(vh);
//
//            vh.tv_group_storemanagement_name.setText(group.get(groupPosition));
//
//
//            //箭头的切换
//            if (isExpanded) {
//                vh.img_group.setImageResource(R.mipmap.array_up);
//            } else {
//                vh.img_group.setImageResource(R.mipmap.array_down);
//            }
//            return convertView;
//
//        }
//
//        /**
//         * 显示：child
//         */
//        @Override
//        public View getChildView(final int groupPosition, final int childPosition,
//                                 boolean isLastChild, View convertView, final ViewGroup parent) {
//            StoreManagementActivity.StoreManagementAdapter.ViewHolder vh;
//            if (convertView == null) {
//                convertView = LayoutInflater.from(mActivity).inflate(
//                        R.layout.storemanagement_child_list, null);
//                vh = new StoreManagementActivity.StoreManagementAdapter.ViewHolder();
//                vh.et_child_store_message_name = (EditText) convertView.findViewById(R.id.et_child_store_message_name);
//                vh.et_child_store_message_telephone = (EditText) convertView.findViewById(R.id.et_child_store_message_telephone);
//                vh.et_child_store_message_adress = (EditText) convertView.findViewById(R.id.et_child_store_message_adress);
//                vh.et_child_store_details_introduce = (EditText) convertView.findViewById(R.id.et_child_store_details_introduce);
//                vh.et_child_personal_details_material = (EditText) convertView.findViewById(R.id.et_child_personal_details_material);
//                vh.et_personal_details_telephone = (EditText) convertView.findViewById(R.id.et_personal_details_telephone);
//                vh.et_child_personal_details_id = (EditText) convertView.findViewById(R.id.et_child_personal_details_id);
//                vh.et_child_detailed_address_street = (EditText) convertView.findViewById(R.id.et_child_detailed_address_street);
//                vh.et_child_verification_code_num = (EditText) convertView.findViewById(R.id.et_child_verification_code_num);
//
//                vh.tv_child_store_thumbnail_num = (TextView) convertView.findViewById(R.id.tv_child_store_thumbnail_num);
//                vh.tv_child_address = (TextView) convertView.findViewById(R.id.tv_child_address);
//                vh.tv_child_verification_code_get = (TextView) convertView.findViewById(R.id.tv_child_verification_code_get);
//
//                vh.rly_child_submit = (RelativeLayout) convertView.findViewById(R.id.rly_child_submit);
//                vh.sb_child_change_alpha = (SeekBar) convertView.findViewById(R.id.sb_child_change_alpha);
//                vh.id_child_phone = (ImageView) convertView.findViewById(R.id.id_child_phone);
//
//                vh.gridview_child_store_thumbnail = (MyGridView) convertView.findViewById(R.id.gridview_child_store_thumbnail);
//                vh.gridview_child_store_details = (MyGridView) convertView.findViewById(R.id.gridview_child_store_details);
//                vh.gridview_child_business_qualification = (MyGridView) convertView.findViewById(R.id.gridview_child_business_qualification);
//
//            } else {
//                vh = (StoreManagementActivity.StoreManagementAdapter.ViewHolder) convertView.getTag();
//            }
//            convertView.setTag(vh);
//
//
//            vh.gridview_child_store_thumbnail.setAdapter(storeimgAdapter);
//
//
//            vh.gridview_child_store_thumbnail.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//                @Override
//                public void onItemClick(AdapterView<?> parent, View view, int position, long l) {
//                    selectimgcode = 1;
//                    if (position == parent.getChildCount() - 1) {
//                        Log.e("ssss", "点击" + groupPosition + "组第" + childPosition + "个");
//
//                        PhotoPickerIntent intent = new PhotoPickerIntent(mActivity);
//                        intent.setSelectModel(SelectModel.MULTI);
//                        intent.setShowCarema(true); // 是否显示拍照
//                        intent.setMaxTotal(9); // 最多选择照片数量，默认为9
//                        intent.setSelectedPaths(imagePaths); // 已选中的照片地址， 用于回显选中状态
//                        startActivityForResult(intent, REQUEST_CAMERA_CODE);
//                    } else {
//                        PhotoPreviewIntent intent = new PhotoPreviewIntent(mActivity);
//                        intent.setCurrentItem(position);
//                        intent.setPhotoPaths(imagePaths);
//                        startActivityForResult(intent, REQUEST_PREVIEW_CODE);
//                    }
//                }
//            });
//
//            return convertView;
//        }
//
//        class ViewHolder {
//            private ImageView img_group;
//            private TextView tv_group_storemanagement_name;
//            private EditText et_child_store_message_name, et_child_store_message_telephone, et_child_store_message_adress,
//                    et_child_store_details_introduce, et_child_personal_details_material, et_personal_details_telephone,
//                    et_child_personal_details_id, et_child_detailed_address_street, et_child_verification_code_num;
//            private TextView tv_child_store_thumbnail_num, tv_child_address, tv_child_verification_code_get;
//            private RelativeLayout rly_child_submit;
//            private SeekBar sb_child_change_alpha;
//            private ImageView id_child_phone;
//            private MyGridView gridview_child_store_thumbnail, gridview_child_store_details, gridview_child_business_qualification;
//        }
//
//        @Override
//        public boolean isChildSelectable(int groupPosition, int childPosition) {
//            return false;
//        }
//
//        @Override
//        public boolean hasStableIds() {
//            return false;
//        }
//    }
//
//    @Override
//    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == RESULT_OK) {
//            switch (requestCode) {
//                case REQUEST_CAMERA_CODE:
//                    loadAdpater(data.getStringArrayListExtra(PhotoPickerActivity.EXTRA_RESULT));
//
//                    break;
//                case REQUEST_PREVIEW_CODE:
//                    loadAdpater(data.getStringArrayListExtra(PhotoPreviewActivity.EXTRA_RESULT));
//
//                    break;
//            }
//        }
//    }
//
//    //图片添加 ++++
//    private void loadAdpater(List<String> paths) {
//        switch (selectimgcode) {
//            case 1://门店缩略图
//                if (imagePaths == null) {
//                    imagePaths = new ArrayList<>();
//                }
//                imagePaths.clear();
//                imagePaths.addAll(paths);
//                if (stroreimglist == null) {
//                    stroreimglist = new ArrayList<StroreimgReq>();
//                }
//                stroreimglist.clear();
//                for (int i = 0; i < imagePaths.size(); i++) {
//                    StroreimgReq strorereq = new StroreimgReq();
//                    Log.e("ssss", "门店缩略图img ==>" + imagePaths.get(i));
//
//                    strorereq.setImgpath(imagePaths.get(i));
//                    stroreimglist.add(strorereq);
//                }
//                if (stroreimglist.size() < 9) {
//                    StroreimgReq req = new StroreimgReq();
//                    req.setImgpath("");
//                    stroreimglist.add(req);
//                }
//
////                if (storeimgAdapter == null) {
////                    storeimgAdapter = new StoreimgAdapter(stroreimglist);
////                    gridview_store_thumbnail.setAdapter(storeimgAdapter);
////
////                } else {
//
//                storeimgAdapter.notifyDataSetChanged();
////                }
//                break;
////            case 2://门店详情
////                if (stroredetailsPaths == null) {
////                    stroredetailsPaths = new ArrayList<String>();
////                }
////                stroredetailsPaths.clear();
////                stroredetailsPaths.addAll(paths);
////
////                if (stroredetailslist == null) {
////                    stroredetailslist = new ArrayList<StorethumbnailReq>();
////                }
////                stroredetailslist.clear();
////                for (int i = 0; i < stroredetailsPaths.size(); i++) {
////                    StorethumbnailReq storethumbnailReq = new StorethumbnailReq();
////                    Log.e("ssss", "门店详情img ==>" + stroredetailsPaths.get(i));
////
////                    storethumbnailReq.setImgpath(stroredetailsPaths.get(i));
////                    stroredetailslist.add(storethumbnailReq);
////                }
////                if (stroredetailslist.size() < 9) {
////                    StorethumbnailReq req = new StorethumbnailReq();
////                    req.setImgpath("");
////                    stroredetailslist.add(req);
////                }
////
////                if (storethumbnailAdapter == null) {
////                    storethumbnailAdapter = new ApplyBusinessActivity.StorethumbnailAdapter(stroredetailslist);
////                    gridview_store_thumbnail.setAdapter(storethumbnailAdapter);
////                    Log.e("ssss", "2222");
////
////                } else {
////                    Log.e("ssss", "33333");
////
////                    storethumbnailAdapter.notifyDataSetChanged();
////                }
////                break;
////
////
////            case 3://营业资质
////                if (businessqfcatPaths == null) {
////                    businessqfcatPaths = new ArrayList<String>();
////                }
////                businessqfcatPaths.clear();
////                businessqfcatPaths.addAll(paths);
////
////                if (businessqfcatlist == null) {
////                    businessqfcatlist = new ArrayList<BusinessqfcatReq>();
////                }
////                businessqfcatlist.clear();
////                for (int i = 0; i < businessqfcatPaths.size(); i++) {
////                    BusinessqfcatReq businessqfcatReq = new BusinessqfcatReq();
////                    Log.e("ssss", "营业资质img ==>" + businessqfcatPaths.get(i));
////
////                    businessqfcatReq.setImgpath(businessqfcatPaths.get(i));
////                    businessqfcatlist.add(businessqfcatReq);
////                }
////                if (businessqfcatlist.size() < 9) {
////                    BusinessqfcatReq req = new BusinessqfcatReq();
////                    req.setImgpath("");
////                    businessqfcatlist.add(req);
////                }
////
////                if (businessqfcatAdapter == null) {
////                    businessqfcatAdapter = new ApplyBusinessActivity.BusinessqfcatAdapter(businessqfcatlist);
////                    gridview_business_qualification.setAdapter(businessqfcatAdapter);
////                    Log.e("ssss", "444");
////
////                } else {
////                    Log.e("ssss", "5555");
////
////                    businessqfcatAdapter.notifyDataSetChanged();
////                }
////                break;
//        }
//
//    }
//
//    //门店缩略图Adapter  ++++
//    private class StoreimgAdapter extends BaseAdapter {
//        private List<StroreimgReq> listUrls;
//
//        public StoreimgAdapter(List<StroreimgReq> listUrls) {
//            this.listUrls = listUrls;
//        }
//
//        @Override
//        public int getCount() {
//            return listUrls.size();
//        }
//
//        @Override
//        public StroreimgReq getItem(int position) {
//            return listUrls.get(position);
//        }
//
//        @Override
//        public long getItemId(int position) {
//            return position;
//        }
//
//        @Override
//        public View getView(int position, View convertView, ViewGroup parent) {
//            StoreManagementActivity.StoreimgAdapter.ViewHolder vh = null;
//
//            if (convertView == null) {
//                convertView = LayoutInflater.from(mActivity).inflate(R.layout.store_img_list, null);
//                vh = new StoreManagementActivity.StoreimgAdapter.ViewHolder();
//                vh.imageView = (ImageView) convertView.findViewById(R.id.imageView11);
//                // 重置ImageView宽高
//                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(columnWidth - 10, columnWidth - 10);
//                vh.imageView.setLayoutParams(params);
//                convertView.setTag(vh);
//            } else {
//
//                vh = (StoreManagementActivity.StoreimgAdapter.ViewHolder) convertView.getTag();
//            }
//
//
//            if (getItem(position).getImgpath().length() > 0) {
//                Glide.with(mActivity)
//                        .load(new File(getItem(position).getImgpath()))
//                        .placeholder(R.mipmap.default_error)
//                        .error(R.mipmap.default_error)
//                        .centerCrop()
//                        .crossFade()
//                        .into(vh.imageView);
//            } else {
//                Glide.with(mActivity)
//                        .load(new File(getItem(position).getImgpath()))
//                        .placeholder(R.mipmap.img_add)
//                        .error(R.mipmap.img_add)
//                        .centerCrop()
//                        .crossFade()
//                        .into(vh.imageView);
//            }
//            return convertView;
//
//        }
//
//        private class ViewHolder {
//            ImageView imageView;
//        }
//    }
//
//}
